#!/usr/bin/env python
'''
进制之间的转换
'''

def test():
    # 二进制转换成十进制：v = “0b1111011”
    r = int("0b1111011", 2)
    print(r)

    # 十进制转换成二进制：v = 18
    r = bin(18)
    print(r)

    # 八进制转换成十进制：v = “011”
    r = int('011', 8)
    print(r)

    # 十进制转换成八进制：v = 30
    r = oct(30)
    print(r)

    # 十六进制转换成十进制：v = “0x12”
    r = int('0x12', 16)
    print(r)

    # 十进制转换成十六进制：v = 87
    r = hex(87)
    print(r)


if __name__ == '__main__':
    test()
